#!/bin/bash 

# Date 		: 2021.1.25
# Author	: majin
# Mail 		: xx
# Function	: easy to collect data for func sort 
# Version 	: 1.0
# Update 	: 2021.1.25

RES="\033[0m"
GREEN="\033[32m"
BLUE="\033[36m"
YELLOW="\033[33m"
PURPLE="\033[35m"
RED="\033[31m"

name_msg(){ echo -e "${GREEN}name_msg:  [ `readlink -f $0` ] ${RES}";}
info_msg(){ echo -e "${BLUE}$1 ${RES}";}
warn_msg(){ echo -e "${PURPLE}$1 ${RES}";}

BINARY_NAME=$1
if [[ ! ${BINARY_NAME} ]];then
   warn_msg "UASG: $0 BINARY_NAME";
   exit
fi

nm_result=$(nm -S ${BINARY_NAME} |sort);

IFS=$'\n'
for i in ${nm_result}
do
    # info_msg "${i}"
    is_func=`echo "$i" | grep -P "^[0-9a-f]+[ ]+[0-9a-f]+[ ]+T[ ]+.*"`;
    
    if [[ ${is_func} ]];then
        info_msg "${is_func##* T }"
    fi
done